var _util = require("util/util.js");

var cart = {
    //获取购物车集合
    getCartList: function ( resolve, reject) {
      _util.request({
        url: _util.getServerUrl('/cart/list.do'),
        method: 'post',
        success: resolve,
        error: reject
      });
    },
    //加入购物车
    addCart: function (data, resolve, reject) {
      _util.request({
        url: _util.getServerUrl('/cart/add.do'),
        method: 'post',
        data: data,
        success: resolve,
        error: reject
      });
    },
    //获取购物车中商品数量
    getCartProductCount: function ( resolve, reject) {
      _util.request({
        url: _util.getServerUrl('/cart/get_cart_product_count.do'),
        method: 'post',
        success: resolve,
        error: reject
      });
    },
    //删除购物车
    delete: function (data, resolve, reject) {
      _util.request({
        url: _util.getServerUrl('/cart/delete.do'),
        method: 'post',
        data: data,
        success: resolve,
        error: reject
      });
    },
    updateCount : function (data, resolve, reject) {
      _util.request({
        url: _util.getServerUrl('/cart/update_count.do'),
        method: 'post',
        data: data,
        success: resolve,
        error: reject
      });
    },
    selectAll : function (resolve, reject) {
      _util.request({
        url: _util.getServerUrl('/cart/select_all.do'),
        method: 'post',
        success: resolve,
        error: reject
      });
    },
    unSelectAll : function (resolve, reject) {
      _util.request({
        url: _util.getServerUrl('/cart/un_select_all.do'),
        method: 'post',
        success: resolve,
        error: reject
      });
    },
    select : function (data, resolve, reject) {
      _util.request({
        url: _util.getServerUrl('/cart/select.do'),
        method: 'post',
        data: data,
        success: resolve,
        error: reject
      });
    },
    unSelect : function (data, resolve, reject) {
      _util.request({
        url: _util.getServerUrl('/cart/un_select.do'),
        method: 'post',
        data: data,
        success: resolve,
        error: reject
      });
    },
}
  
module.exports = cart;